using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NL.HMap
{
    public class MapSampler : MonoBehaviour
    {
        // Start is called before the first frame update

        // Update is called once per frame
        void LateUpdate()
        {
            transform.position = Sample(transform.position);
        }


        public Vector3 Sample(Vector3 pos)
        {
            RaycastHit hit;
            if (Physics.Raycast(pos + Vector3.up * 1000, Vector3.down, out hit, float.MaxValue))
            {
                return hit.point;
            }
            else
            {
                return pos;
            }
        }
    }
}

